//  用于本地存储token信息

export function setToken(token) {
  localStorage.setItem('token', JSON.stringify(token)); // auto reload
}

export function getToken() {
  const tokenString = localStorage ? localStorage.getItem('token'): '';
  let token;
  try {
    if(tokenString) {
      token = JSON.parse(tokenString);
    }
  } catch (e) {
    token = null
  }
  return token;
}
